package com.zhoulz.homework.chaptor02.node;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

public class PacketEncode extends MessageToByteEncoder<Packet>{
	
	@Override
	protected void encode(ChannelHandlerContext ctx, Packet msg, ByteBuf out)
			throws Exception {
//		System.out.println("encode: "+ msg);
		out.writeBytes(Unpooled.buffer(1).writeByte(msg.getType().getValue()));
	}
}
